<%@page import="java.net.URLEncoder"%>
<%@page import="com.jspsmart.upload.SmartUpload"%>
<%@page import="java.io.File"%>
<%@page import="ext.acae2.baseline.web.BaselineCreDocXLS"%>
<%@page import="wt.vc.baseline.ManagedBaseline"%>
<%@page import="com.ptc.netmarkets.util.beans.NmCommandBean"%>
<%@page session="true" language="java" pageEncoding="GBK"%>

<jsp:useBean id="commandBean"       class="com.ptc.netmarkets.util.beans.NmCommandBean"  			scope="request"/>

<%
NmCommandBean commandBeanRep = commandBean;
ManagedBaseline mb = (ManagedBaseline) commandBeanRep.getPageOid().getWtRef().getObject();

String filePath = BaselineCreDocXLS.generateBaselineCreXLS(mb);
File file = new File(filePath);

if (file.exists()) {
	response.reset();
	SmartUpload su = new SmartUpload();
	su.initialize(pageContext);
	su.setContentDisposition(null);
	String encodedFile = URLEncoder.encode(file.getName(), "UTF-8");
	su.downloadFile(filePath,"application/vnd.ms-excel", encodedFile);
  	file.delete();
  	out.clear();
  	out=pageContext.pushBody();
}

%>

<script type="text/javascript">
window.close();
</script>